<?php echo form_open($this->curl . '/edit/'.$this->validation->id, 'id="myform" name="myform" autocomplete="off"')?>
<?php echo form_hidden('id', $this->validation->id)?>
<br />
<table class="nostyle" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td>
		<?php echo $this->validation->error_string?>
		
		<?php echo form_fieldset(T_('General')); ?>
		
			<table class="nostyle forma" width="100%" border="0" cellpadding="3" cellspacing="0">
			<tr>
				<th style="width: 180px;"><?php $this->load->view('_elements/obligatory');?><?php echo T_('Name'); ?></th>
				<td><div class="input_300"><?php echo form_input('name', $this->validation->name, 'class="input-text"')?></div></td>
			</tr>
			<tr>
				<th><?php $this->load->view('_elements/obligatory');?><?php echo $this->account_type_model->fields['category']?></th>
				<td><div class="input_300"><?php echo form_dropdown('category', $this->config->item('account_categories'), array($this->validation->category), 'id="category" onchange="renderData()"', TRUE)?></div></td>
			</tr>
			<tr>
				<th><?php $this->load->view('_elements/obligatory');?><?php echo $this->account_type_model->fields['status']?></th>
				<td><div class="input_300"><?php echo form_dropdown('status', $this->account_type_model->status, array($this->validation->status), null, TRUE)?></div></td>
			</tr>
			<tr>
				<th><?php echo $this->account_type_model->fields['description']?>:</th>
				<td><div class="textarea_80"><?php echo form_textarea('description', $this->validation->description, 'class="input-text"')?></div></td>
			</tr>
			</table>
			
		<?php echo form_fieldset_close(); ?>	
		<br />
		
		<div id="tab_company" style="display: <?php if ($this->validation->category == 3) echo 'block'; else echo 'none'; ?>">
			<table class="nostyle" width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td style="vertical-align: top !important">
					<?php echo form_fieldset(T_('Price')); ?>
					<table class="nostyle" width="400" border="0" cellpadding="3" cellspacing="0" style="margin: 0 auto">
					<tr>
						<th></th>
						<th></th>
						<th class="center"><?php echo $this->account_type_model->fields['price_total']?></th>
						<th class="center"><?php echo $this->account_type_model->fields['price_tests']?></th>
						<th class="center"><?php echo $this->account_type_model->fields['price_roll_over']?></th>
					</tr>
					<tr>
						<td><?php echo form_radio('price_type', 1, ($this->validation->price_type == 1) ? true : false); ?></td>
						<th><?php echo T_('Annual'); ?></th>
						<td><div class="input_80 center"><?php echo form_input('price_total_annual', $this->validation->price_total_annual, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('price_tests_annual', $this->validation->price_tests_annual, 'class="input-text"')?></div></td>
						<td class="center"><?php echo form_checkbox('price_roll_over_annual', 1, ($this->validation->price_roll_over_annual) ? TRUE : FALSE, 'class="checkbox"')?></td>
					</tr>
					<tr>
						<td><?php echo form_radio('price_type', 2, ($this->validation->price_type == 2) ? true : false); ?></td>
						<th><?php echo T_('Monthly'); ?></th>
						<td><div class="input_80 center"><?php echo form_input('price_total_monthly', $this->validation->price_total_monthly, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('price_tests_monthly', $this->validation->price_tests_monthly, 'class="input-text"')?></div></td>
						<td class="center"><?php echo form_checkbox('price_roll_over_monthly', 1,  ($this->validation->price_roll_over_monthly) ? TRUE : FALSE, 'class="checkbox"')?></td>
					</tr>
					</table>
					<?php echo form_fieldset_close(); ?>
				</td>
				<td style="width: 22px; vertical-align: top !important; padding-top: 4px"><?php echo form_radio('carte_type', 1, ($this->validation->carte_type == 1) ? true : false); ?></td>
				<td style="vertical-align: top !important; width: 220px">
					<?php echo form_fieldset(T_('A la Carte simple')); ?>
					<table class="nostyle" width="300" border="0" cellpadding="3" cellspacing="0">
					<tr>
						<th class="center"><?php echo $this->account_type_model->fields['carte_simple_tests']?></th>
						<th class="center"><?php echo $this->account_type_model->fields['carte_simple_price']?></th>
						<th style="width: 94px"></th>
					</tr>
					<tr>
						<td><div class="input_80 center"><?php echo form_input('carte_simple_tests_1', $this->validation->carte_simple_tests_1, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_simple_price_1', $this->validation->carte_simple_price_1, 'class="input-text"')?></div></td>
						<td></td>
					</tr>
					<tr>
						<td><div class="input_80 center"><?php echo form_input('carte_simple_tests_2', $this->validation->carte_simple_tests_2, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_simple_price_2', $this->validation->carte_simple_price_2, 'class="input-text"')?></div></td>
						<td></td>
					</tr>
					<tr>
						<td><div class="input_80 center"><?php echo form_input('carte_simple_tests_3', $this->validation->carte_simple_tests_3, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_simple_price_3', $this->validation->carte_simple_price_3, 'class="input-text"')?></div></td>
						<td></td>
					</tr>
					</table>
					<?php echo form_fieldset_close(); ?>
				</td>
			</tr>
			<tr>
				<td></td>
				<td style="width: 22px; vertical-align: top !important; padding-top: 4px"><?php echo form_radio('carte_type', 2, ($this->validation->carte_type == 2) ? true : false); ?></td>
				<td>
					<?php echo form_fieldset(T_('A la Carte range')); ?>
					<table class="nostyle" width="300" border="0" cellpadding="3" cellspacing="0">
					<tr>
						<th class="center"><?php echo $this->account_type_model->fields['carte_range_from']?></th>
						<th class="center"><?php echo $this->account_type_model->fields['carte_range_to']?></th>
						<th class="center"><?php echo $this->account_type_model->fields['carte_range_price']?></th>
					</tr>
					<tr>
						<td><div class="input_80 center"><?php echo form_input('carte_range_from_1', $this->validation->carte_range_from_1, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_range_to_1', $this->validation->carte_range_to_1, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_range_price_1', $this->validation->carte_range_price_1, 'class="input-text"')?></div></td>
					</tr>
					<tr>
						<td><div class="input_80 center"><?php echo form_input('carte_range_from_2', $this->validation->carte_range_from_2, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_range_to_2', $this->validation->carte_range_to_2, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_range_price_2', $this->validation->carte_range_price_2, 'class="input-text"')?></div></td>
					</tr>
					<tr>
						<td><div class="input_80 center"><?php echo form_input('carte_range_from_3', $this->validation->carte_range_from_3, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_range_to_3', $this->validation->carte_range_to_3, 'class="input-text"')?></div></td>
						<td><div class="input_80 center"><?php echo form_input('carte_range_price_3', $this->validation->carte_range_price_3, 'class="input-text"')?></div></td>
					</tr>
					</table>
					<?php echo form_fieldset_close(); ?>
				</td>
			</tr>
			</table>
		</div>
		
		<div id="tab_contributor" style="display: <?php if ($this->validation->category == 4) echo 'block'; else echo 'none'; ?>">
		
			<?php echo form_fieldset(T_('Reward Condition')); ?>
		
			<table class="nostyle forma" width="100%" border="0" cellpadding="3" cellspacing="0">
			<tr>
				<th style="width: 180px;"><?php echo $this->account_type_model->fields['reward_profit']?></th>
				<td><div class="input_300"><?php echo form_input('reward_profit', $this->validation->reward_profit, 'class="input-text"')?></div></td>
			</tr>
			<tr>
				<th><?php echo $this->account_type_model->fields['reward_one_time']?></th>
				<td><div class="input_300"><?php echo form_input('reward_one_time', $this->validation->reward_one_time, 'class="input-text"')?></div></td>
			</tr>
			</table>
			
			<?php echo form_fieldset_close(); ?>
		
		</div>
		
		<br />
		<table class="nostyle forma" width="100%" border="0" cellpadding="3" cellspacing="0">
		<tr>
			<th style="width: 180px;"></th>
			<td>			
				<input name="edit" type="submit" class="btn btn_save" id="submit" value="<?php echo T_('Submit')?>" />
				<input name="reset"  type="reset"  class="btn btn_clear" id="reset" value="<?php echo T_('Reset')?>" onclick="resetForm();" />
				<input name="delete" type="button" class="btn btn_delete" id="delete" value="<?php echo T_('Delete')?>" onclick="if (confirm('<?php echo T_('Are you sure you want to delete this data?')?>')) location='/admin/<?php echo $this->curl; ?>/delete/<?php echo $this->validation->id?>';return false;" />
			</td>
		</tr>
		</table>
	</td>
</tr>
</table>

<?php echo form_close()?>

<script>
function renderData()
{
	switch ($('#category').val())
	{
		case '2':
			$('#tab_company').hide();
			$('#tab_contributor').hide();
			break;

		case '3':
			$('#tab_contributor').hide();
			$('#tab_company').show();
			break;

		case '4':
			$('#tab_company').hide();
			$('#tab_contributor').show();
			break;

		default:
			$('#tab_company').hide();
			$('#tab_contributor').hide();		
			break;
	}	
}

function resetForm()
{
	$('#create_form input[type=text]').val('');
	$('#category').val(<?php echo $this->validation->category; ?>);
	renderData();
	
}
</script>